//
//  LJJPriceView.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/22.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJPriceView.h"

@interface LJJPriceView ()

@property (strong, nonatomic) UILabel *allLabel;    /** 合计 **/
@property (strong, nonatomic) UIButton *payButton;    /** 支付 **/

@end

@implementation LJJPriceView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.priceLabel];
        [self addSubview:self.allLabel];
        [self addSubview:self.payButton];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(7);
        make.top.equalTo(weakSelf.mas_top).offset(10);
        make.height.equalTo(@17);
        make.right.equalTo(weakSelf.payButton.mas_left).offset(-20);
    }];
    [_allLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.priceLabel.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(70, 14));
        make.left.equalTo(weakSelf.mas_left).offset(60);
    }];
    [_payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(110, 35));
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).offset(-20);
    }];
}
- (void)payButtonMethod:(UIButton *)sender
{
    if (_payBlock) {
        _payBlock();
    }
}
#pragma mark -
#pragma mark - lazy method
- (UILabel *)priceLabel
{
    if (!_priceLabel) {
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.text = @"";
        _priceLabel.textColor = [UIColor blackColor];
    }
    return _priceLabel;
}
- (UILabel *)allLabel
{
    if (!_allLabel) {
        _allLabel = [[UILabel alloc] init];
        _allLabel.font = [UIFont systemFontOfSize:13.0];
        _allLabel.text = @"(全场包邮)";
        _allLabel.textColor = RGB(87, 87, 87, 1);
    }
    return _allLabel;
}
- (UIButton *)payButton
{
    if (!_payButton) {
        _payButton = [UIButton buttonWithType: UIButtonTypeCustom];
        [_payButton setImage:[UIImage imageNamed:@"购物车界面去结算按钮"] forState:UIControlStateNormal];
        [_payButton addTarget:self action:@selector(payButtonMethod:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _payButton;
}
@end
